function extractAttributes(element) {
  const attrVals = [];
  const indexOfRight = element.indexOf('>');
  const indexOfFirstSpace = element.indexOf(' ');
  if (indexOfFirstSpace < 0 || indexOfFirstSpace > indexOfRight) return attrVals;
  // console.log(indexOfRight, indexOfFirstSpace);
  const openTag = element.slice(indexOfFirstSpace+1, indexOfRight).replace(' /', '');
  const props = openTag.split('" ');
  for (const prop of props) {
    let [attr, val] = prop.split('=');
    val = val.replaceAll('"', '');
    attrVals.push(`${attr}, ${val}`);
  }
  // console.log(openTag);
  return attrVals;
}


let output = extractAttributes('<span class="red"></span>');
console.log(output);